package com.sptpc.learnspring;

import com.sptpc.learnspring.controller.inteceptor.PerformaceInteceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableTransactionManagement
@ServletComponentScan
@SpringBootApplication
public class MoreMvcInteceptorApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(MoreMvcInteceptorApplication.class, args);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new PerformaceInteceptor())
                .addPathPatterns("/category/**")
                .addPathPatterns("/drink/**");
    }
}
